<?php
if (!defined('XOOPS_ROOT_PATH')) {
	exit();
}

function xoops_module_install_xoopsgallery(&$module){
	// echo "<strong>Important!</strong> Don't forget to configure either NetPBM or ImageMagick in the Administration Menu > XoopsGallery > Preferences form.";
}

function xoops_module_uninstall_xoopsgallery(&$module){
	xoops_module_uninstall_rmdir(XOOPS_ROOT_PATH.'/modules/xoopsgallery/cache/albums', false);
	return true;
}


function xoops_module_uninstall_rmdir($dirname, $rm_self = true){
	if ($handle = @opendir($dirname)) {
        while ($entry = readdir($handle)) {
			if ($entry != '.' && $entry != '..') {
				if (!is_dir($dirname.'/'.$entry) && ($rm_self || $entry != 'index.html')) {
					unlink($dirname.'/'.$entry);
				} else {
					xoops_module_uninstall_rmdir($dirname.'/'.$entry);
				}
			}
		}
		closedir($handle);
		if ($rm_self) {
			rmdir($dirname);
		}
		return true;
	} else {
		return false;
	}
}


// comment callback functions

function xoopsgallery_com_update($image_id, $total_num){
	$image_handler =& xoops_getmodulehandler('image');
	$image =& $image_handler->get($image_id);
	$image->setVar('image_comments', $total_num);
	return $image_handler->insert($image);
}

function xoopsgallery_com_approve(&$comment){
	// not used yet
}
?>